open Castling;;

module CharPG = ParserGenerator (CharToken);;
open CharPG;;

let rec compilation_unit = lazy !! (
	one_of ~name:"compilation_unit" [
		"procedure_unit", procedure_declaration;
		"subunit", subunit]
) and subunit = lazy !! (
	element 'S' >> element '(' >> structured_name >> element ')' >>
	one_of ~name:"compilation_unit" [
		"procedure_unit", procedure_declaration]
) and structured_name = lazy !! (
	one_of ~name:"structured_name" [
		"child_name", structured_name >> element '.' >> subprogram_name;
		"attribute_name", structured_name >> element 'a';
		"simple_name", subprogram_name]
) and subprogram_name = lazy !! (
	one_of ~name:"name" [
		"identifier_name", element 'i';
		"operator", element 's']
) and procedure_declaration = lazy !! (
	element 'P' >>
	one_of ~name:"hoge" [
		"aaa", structured_name >> element '1']
);;

debug := true;;
runtime_debug := true;;
generate compilation_unit;;
